package com.hiyee.platform.factory;

import com.hiyee.platform.service.FileUploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.Map;

/**
 * 异步处理 excel 实现类
 *
 * @author WangBin
 */
@Component
public class RabbitMqExcelHandle extends IRabbitMqHandle{

    private Map message;
    @Autowired
    private FileUploadService fileUploadService;
    private static RabbitMqExcelHandle rabbitMqExcelHandle;

    @PostConstruct
    public void init() {
        rabbitMqExcelHandle = this;
        rabbitMqExcelHandle.fileUploadService = this.fileUploadService;
    }

    public RabbitMqExcelHandle(){}

    public RabbitMqExcelHandle(Map message) {
        this.message = message;
    }

    @Override
    public void handle() {
        String action = this.message.get("action").toString();
        String filePath = this.message.get("file_path").toString();
        rabbitMqExcelHandle.fileUploadService.handle(action, filePath);
    }
}
